<?

header('Location: Mensajes.php?activo=3');

include ("constantes_envio_mensaje.php");
require "connectdb.php";

if (!isset($_CONFIG))
{
require 'config.php';
require "connectdb.php";
}
//$id=$_SESSION['playerID'];
	
	echo("<PRE>");
	print_r($_POST);
	echo("</PRE>");
        $fromPerson=($_POST['from'])?$_POST['from']:"NULL";
        $toPerson=($_POST['to'])?$_POST['to']:"NULL";

	echo("From $fromPerson, To $toPerson<br>");

        $OKForMessage=true;;

        if (($fromPerson==NULL)||($toPerson==NULL))
        {
                $OKForMessage=false;
               
                if ($_SESSION['isAdmin'])
                $OKForMessage=true;
        }


        if($OKForMessage){
        $mGame=($_POST['forGame'])?$_POST['from']:"NULL";
        $msgtitle=$_POST['txtTitle'];
        $msgtext=$_POST['txtMessage'];
        if($_POST['msgType']=="Article")
                $msgtype="0";
        else
                $msgtype="0"; // Always 0... yet..

        $sql = "INSERT INTO " . $CFG_TABLE[communication] . " (gameID,fromID,toID,title,text,postDate,expireDate,ack,commType) ";
        $sql .= "VALUES ( $mGame , $fromPerson , $toPerson, '$msgtitle', '$msgtext', NOW( ) , NULL , '0', '$msgtype' );";
        mysql_query($sql) or die("can't do query: $sql");;
		}

	$a=1;		

?>
